package mysql

import "gorm.io/gorm"

type Class struct {
	gorm.Model
	ClassName    string  `gorm:"type:varchar(20);comment:课程名称"`
	ClassPrice   float64 `gorm:"type:decimal(10,2);comment:课程价格"`
	ClassAddress string  `gorm:"type:varchar(20);comment:课程地点"`
}

func (c Class) TableName() string {
	return "class"
}

func (c *Class) Find(id int) (result Class, err error) {
	err = DB.Where("id=?", id).Find(&result).Error
	if err != nil {
		return Class{}, err
	}
	return result, nil
}
